// pages/yun.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputValue:"",
    number: 0,
    isCheck: false,
    cart: 0,
    currentIndex: 1,
    keMuList: [
      {
        "imgPath": "../../images/考研.png",
        "value": "考研"
      }, {
        "imgPath": "../../images/四六级.png",
        "value": "四六级"
      }, {
        "imgPath": "../../images/公务员.png",
        "value": "公务员"
      }, {
        "imgPath": "../../images/计算机.png",
        "value": "计算机"
      }, {
        "imgPath": "../../images/教师资格证.png",
        "value": "教资"
      }, {
        "imgPath": "../../images/财务会计.png",
        "value": "财会"
      }, {
        "imgPath": "../../images/专升本考试.png",
        "value": "专升本"
      },
    ],
    itemList: [
      {
        "id": 10,
        "value": "考研数学660题",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      },
      {
        "id": 21,
        "value": "张宇考研数学1000题",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false

      },
      {
        "id": 12,
        "value": "腿姐背诵手册",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      },
      {
        "id": 11,
        "value": '肖秀荣考研政治八套卷',
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      },
      {
        "id": 8,
        "value": "看书",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      }, {
        "id": 9,
        "value": "健身",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      },
      {
        "id": 9,
        "value": "健身",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      },
      {
        "id": 9,
        "value": "健身",
        "pages": 100,
        "img": "../../images/11231.jpg",
        "price": 10,
        "num":0,
        "hasNum":false
      }
    ],
    keMu: [{
      "id": 10,
      "value": "会计类"
    },
    {
      "id": 21,
      "value": "工程类"
    },
    {
      "id": 12,
      "value": "技术类"
    },
    {
      "id": 11,
      "value": '其他'
    }, {
      "id": 10,
      "value": "会计类"
    },
    {
      "id": 21,
      "value": "工程类"
    },
    {
      "id": 12,
      "value": "技术类"
    },
    {
      "id": 11,
      "value": '其他'
    }, {
      "id": 10,
      "value": "会计类"
    },
    {
      "id": 21,
      "value": "工程类"
    },
    {
      "id": 12,
      "value": "技术类"
    },

    {
      "id": 11,
      "value": '其他'
    }],
  },
  addCart(e) {
    const index = e.currentTarget.dataset.index;
    let itemList = this.data.itemList;
    let num = itemList[index].num;
    num = num + 1;
    itemList[index].num = num;
    itemList[index].hasNum = true;
    this.setData({
      itemList: itemList
    });
    var cartNum = this.data.cart + 1
    this.setData({
      cart: cartNum,
      isCheck: true,
      number: num
    })
  },
  addCount(e) {
    const index = e.currentTarget.dataset.index;
    let itemList = this.data.itemList;
    let num = itemList[index].num;
    var cartNum = this.data.cart + 1
    num = num + 1;
    itemList[index].num = num;
    this.setData({
      itemList: itemList,
      cart:cartNum
    });
  },
  minusCount(e) {
    const index = e.currentTarget.dataset.index;
    let itemList = this.data.itemList;
    let num = itemList[index].num;
    let hasNum = itemList[index].hasNum;
    var cartNum = this.data.cart - 1
    if (num <= 1) {
      hasNum = false
    }
    num = num - 1;
    itemList[index].num = num;
    itemList[index].hasNum = hasNum;
    this.setData({
      itemList: itemList,
      cart:cartNum
    });
  },
  onButtonClick: function () {
    // 要跳转的页面路径
    var targetPagePath = '../yun/yun';
    this.setData({
      currentIndex: 1
    })
    // 使用wx.navigateTo方法跳转到指定页面
    wx.redirectTo({
      url: targetPagePath,
      disableScroll: true
    });

  },
  goToList: function () {
    // 要跳转的页面路径
    var targetPagePath = '../print/print';
    // 使用wx.navigateTo方法跳转到指定页面
    wx.navigateTo({
      url: targetPagePath,
      disableScroll: true
    });
  },
  clickZhuye: function () {
    // 要跳转的页面路径
    var targetPagePath = '../index/index';
    this.setData({
      currentIndex: 0
    })
    // 使用wx.navigateTo方法跳转到指定页面
    wx.redirectTo({
      url: targetPagePath,
      disableScroll: true
    });

  },
  clickWod: function () {
    // 要跳转的页面路径
    var targetPagePath = '../my/my';
    // 使用wx.navigateTo方法跳转到指定页面
    this.setData({
      currentIndex: 2
    })
    wx.redirectTo({
      url: targetPagePath,
      disableScroll: true
    });
  },

  getInputValue(e){
    this.setData({
      inputValue: e.detail.value
    })
  },
  search: function () {
    console.log("进入云资料搜索页")
    // 要跳转的页面路径
    var targetPagePath = '../search/search';
    // 使用wx.navigateTo方法跳转到指定页面
    wx.navigateTo({
      url: targetPagePath,
      disableScroll: true
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})